#ifndef LIN_MESSAGE_H
#define LIN_MESSAGE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "drv.h"
#define CA_Contrl_ID (0X15U)
#define Report_Value_ID (0X16U)

typedef enum
{
    DIAGNOSTIC_WAIT = 0,
    DIAGNOSTIC_PASS = 1,
    SHORT_GND = 2,
    SHORT_VCC = 3,
    UNUSED = 4,
    OUT_RANGE = 5,
    UNDEFINED = 6,
    HVH_CURRSENS_FLT_SNA_7 = 7
}HVH_CurrSens_Flt_e;

typedef enum
{
    NO_HIGH_V_DETECTED = 0,
    HIGH_V_EFFECTIVE = 1,
    UNDERVOLTAGE = 2,
    OVERVOLTAGE = 3
}HVH_HV_Voltage_Valid_e;

typedef enum
{
    HVH_MODE_POWER = 0,
    HVH_MODE_TEMP ,
    HVH_MODE_OFF
}HVH_ON_OFF_e;

typedef enum
{
    NO_SHORT_CIRCUIT = 0,
    SHORT_CIRCUIT = 1
}HVH_Off_ShrtCurr_e;

typedef enum
{
    HVH_OFF = 0,
    HVH_ON = 1,
    HVH_DEG = 2,
    HVH_STOP = 3,
    HVH_SHUTDOWN = 4,
    HVH_SHORTED = 5,
    HVH_NO_RESET = 6,
    HVH_RUNSTATUS_SNA_7 = 7
}HVH_RunStatus_e;

typedef enum
{
    IN_THE_RANGE = 0,
    OUT_OF_RANGE = 1
}HVH_Sp_ExtPwrSup_Flt_e;

typedef enum
{
    NO_TIMEOUT = 0,
    TIMEOUT = 1
}HVH_Sp_LIN_Flt_e;

typedef enum
{
    NO_OVERTEMP = 0,
    OVERTEMP = 1
}HVH_TempLim_e;

typedef enum
{
    NO_FAULT = 0,
    FAULT = 1
}HVH_TempSens_Flt_e;

typedef enum
{
    NO_ERR_DETECTED = 0,
    ERR_DETECTED = 1
}RsErr_HVH_e;

typedef struct
{
    uint8_t id;
    uint8_t len;
    union
    {
        uint8_t data[8];
        struct
        {
            uint32_t Rev_0_32:32; /* bit 00-31 32 */
            uint32_t HVH_power_ratio:8; /* bit 32-39  8 */
            uint32_t Temp_set:8; /* bit 40-47  8 */
            HVH_ON_OFF_e HVH_ON_OFF:2; /* bit 48-48  1 */
            uint32_t Rev_15:14; /* bit 49-63 15 */
        }sig;
    }msg;
}CA_Contrl_t;

typedef struct
{
    uint8_t id;
    uint8_t len;
    union
    {
        uint8_t data[8];
        struct
        {
            HVH_CurrSens_Flt_e HVH_CurrSens_Flt:5; /* bit 00-04  5 */
            uint32_t Rev_5_1:1; /* bit 05-05  1 */
            RsErr_HVH_e RsErr_HVH:1; /* bit 06-06  1 */
            uint32_t Rev_7_1:1; /* bit 07-07  1 */
            uint32_t Tempe_of_OutWater:8; /* bit 08-15  8 */
            uint32_t Temp_of_InWater:8; /* bit 16-23  8 */
            HVH_RunStatus_e HVH_RunStatus:3; /* bit 24-26  3 */
            uint32_t HVH_HeaterCircuits:2; /* bit 27-28  2 */
            HVH_HV_Voltage_Valid_e HVH_HV_Voltage_Valid:2; /* bit 29-30  2 */
            HVH_TempSens_Flt_e HVH_TempSens_Flt:1; /* bit 31-31  1 */
            HVH_TempLim_e HVH_TempLim:1; /* bit 32-32  1 */
            HVH_Sp_LIN_Flt_e HVH_Sp_LIN_Flt:1; /* bit 33-33  1 */
            HVH_Sp_ExtPwrSup_Flt_e HVH_Sp_ExtPwrSup_Flt:1; /* bit 34-34  1 */
            HVH_Off_ShrtCurr_e HVH_Off_ShrtCurr:1; /* bit 35-35  1 */
            uint32_t Rev_36_4:4; /* bit 36-39  4 */
            uint32_t HVH_InternalPCBTemp:8; /* bit 40-47  8 */
            uint32_t power:8; /* bit 48-55  8 */
            uint32_t HVH_HV_Voltage:8; /* bit 56-63  8 */
        }sig;
    }msg;
}Report_Value_t;

extern CA_Contrl_t CA_Contrl;
extern Report_Value_t Report_Value;

/* #define USE_IL_LIB */

#ifdef USE_IL_LIB

#define IL_HVH_power_ratio_TX(X)	\
{	\
	CA_Contrl.msg.sig.HVH_power_ratio = (X);	\
}

#define IL_Temp_set_TX(X)	\
{	\
	CA_Contrl.msg.sig.Temp_set = (X);	\
}

#define IL_HVH_ON_OFF_TX(X)	\
{	\
	CA_Contrl.msg.sig.HVH_ON_OFF = (X);	\
}

#define IL_HVH_CurrSens_Flt_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_CurrSens_Flt = (X);	\
}

#define IL_RsErr_HVH_TX(X)	\
{	\
	Report_Value.msg.sig.RsErr_HVH = (X);	\
}

#define IL_Tempe_of_OutWater_TX(X)	\
{	\
	Report_Value.msg.sig.Tempe_of_OutWater = (X);	\
}

#define IL_Temp_of_InWater_TX(X)	\
{	\
	Report_Value.msg.sig.Temp_of_InWater = (X);	\
}

#define IL_HVH_RunStatus_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_RunStatus = (X);	\
}

#define IL_HVH_HeaterCircuits_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_HeaterCircuits = (X);	\
}

#define IL_HVH_HV_Voltage_Valid_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_HV_Voltage_Valid = (X);	\
}

#define IL_HVH_TempSens_Flt_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_TempSens_Flt = (X);	\
}

#define IL_HVH_TempLim_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_TempLim = (X);	\
}

#define IL_HVH_Sp_LIN_Flt_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_Sp_LIN_Flt = (X);	\
}

#define IL_HVH_Sp_ExtPwrSup_Flt_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_Sp_ExtPwrSup_Flt = (X);	\
}

#define IL_HVH_Off_ShrtCurr_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_Off_ShrtCurr = (X);	\
}

#define IL_HVH_InternalPCBTemp_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_InternalPCBTemp = (X);	\
}

#define IL_HVH_running_current_TX(X)	\
{	\
	Report_Value.msg.sig.power = (X);	\
}

#define IL_HVH_HV_Voltage_TX(X)	\
{	\
	Report_Value.msg.sig.HVH_HV_Voltage = (X);	\
}

#endif

void lin_msg_init(void);

#ifdef __cplusplus
}
#endif

#endif
/* EOF */
